package com.example.common.entity;

import jakarta.persistence.*;
import lombok.Data;

import java.math.BigInteger;

@Entity
@Table(name = "tool_email_config")
@Data
public class ToolEmailConfig {
    @Id
    @Column(name = "config_id", nullable = false)
    private BigInteger configId;
    
    // from_user
    @ManyToOne
    @JoinColumn(name = "from_user", referencedColumnName = "username")
    private SysUser fUser;
    
    private String host, pass, port;
    
    // user
    @ManyToOne
    @JoinColumn(name = "user", referencedColumnName = "username")
    private SysUser sysUser;
    
    public BigInteger getConfigId() {
        return configId;
    }
    
    public void setConfigId(BigInteger configId) {
        this.configId = configId;
    }
    
    @Transient
    public String getFromUser() {
        return fUser.getUsername();
    }
    
    public void setFromUser(String fromUser) {
        SysUser user = new SysUser();
        user.setUsername(fromUser);
        this.fUser = user;
    }
    
    public String getHost() {
        return host;
    }
    
    public void setHost(String host) {
        this.host = host;
    }
    
    public String getPass() {
        return pass;
    }
    
    public void setPass(String pass) {
        this.pass = pass;
    }
    
    public String getPort() {
        return port;
    }
    
    public void setPort(String port) {
        this.port = port;
    }
    
    @Transient
    public String getUser() {
        return sysUser.getUsername();
    }
    
    public void setUser(String user) {
        SysUser sUser = new SysUser();
        sUser.setUsername(user);
        this.sysUser = sUser;
    }
}
